package acm.蓝桥杯二分前缀;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

// 找到第一个大于等于x的数和第一个小于x的数，取最小差值即是该学生的不满意度
public class 烦恼的高考志愿 {
    public static int school[];
    public static void main(String[] args) {
        Reader sc=new Reader();
        int n = sc.nextInt();
        int m = sc.nextInt();
        school = new int[n];
        for (int i = 0; i < n; i++) {
            school[i] = sc.nextInt();
        }
        Arrays.sort(school);
        long res = 0;
        int len = school.length-1;
        for (int i = 0; i < m; i++) {
            res += binarySearch(0,len,sc.nextInt());
        }
        System.out.println(res);
    }
    //
    public static int binarySearch(int l,int r, int x){
        while(l<=r){
            int mid = l+((r-l)>>1);
            if(x<=school[mid]){
                r = mid-1;
            }else{
                l = mid+1;
            }
        }
        int floor =Integer.MAX_VALUE,ceil = Integer.MAX_VALUE;
        if (l< school.length){
            ceil = school[l]-x;
        }
        if (r>=0){
            floor = x-school[r];
        }
        return Math.min(floor,ceil);
    }


    static class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }
        public void clear(){
            tokenizer = new StringTokenizer("");
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
//    public BigInteger nextBigInt() {
//        return new BigInteger(next());
//    }
    }

}
